package com.atguigu.testdemo.customer.mapper;

import com.atguigu.testdemo.customer.bean.Customer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {

    @Delete("delete from customer where id = #{id}")
    void deleteCustomer(Long id);

    @Update("update customer c1 set c1.username = #{c.name},c1.age = #{c.age} where c1.id = #{c.id}")
    void updateCustomer(@Param("c") Customer customer);

    @Insert("insert into customer(id , username, age ) values (#{c.id} , #{c.name} , #{c.age} ) ")
    void InsertCustomer(@Param("c") Customer customer);

    @Select(" select id , username as name, age from customer where id = #{id} ")
    Customer selectCustomerById(Long id);

    @Select("select * from customer where username = #{name} and age = #{age}")
    Customer selectCustomerByName(@Param("name") String name , Integer age);

    @Insert("insert into customer( username, age ) values (#{name} , #{age} ) ")
    void InsertCustomerTest(@Param("name") String name , Integer age);

    @Select("${ sql }")
    List<Customer> selectCustomer(String sql);
}
